<?php

/*

User-run Shops (usershop.php)

*/

$page_title = "User-run Shops";
$rank_check = 1;
include "header.inc.php";

print "$openHTML";

$find_owner = fetch("SELECT id,rank FROM members2 WHERE username = '$user' AND game = '$game'");
$find_shop = fetch("SELECT * FROM usershops2 WHERE owner = '$find_owner[id]' AND game = '$game'");

if ($find_owner[rank] == 0)
{
	die("<p align=center class=error>This user has been suspended.</p>$closeHTML");
}

if (!$find_shop[id])
{
	die("This user does not have a shop.$closeHTML");
}

print "<p><b>$find_shop[shop_name]</B> <font size=-1><i>size $find_shop[shop_size]</i></font></p><p>$find_shop[shop_desc]</p>

<p><font face=Verdana size=2 color=#FF0000><b>Below is the website link of your own shop, tell your buddies about your shop to get sells. </b></font></p><p><a href=$base_url/usershop.php?game=$game&user=$user>$base_url/usershop.php?game=$game&user=$user</a></p><p><font face=Verdana size=2 color=#FF0000><b>Besides, your buddies can find your shop within your profile</b></font></p>

<center><table>";

$x = 0;
$query = mysql_query("SELECT * FROM usershops_items2 WHERE owner = '$find_owner[id]' AND price > '0' AND game = '$game' ORDER BY item_id");
while ($array = mysql_fetch_array($query))
{
	$get_item = fetch("SELECT * FROM items2 WHERE id = '$array[item_id]' AND game = '$game'");
	$y = $x % 5;
	if ($y == 0)
	{
		echo "<tr>";
	}
	echo "<td><p align=center><a href='usershop.pro.php?game=$game&user=$user&id=$array[id]&price=$array[price]' onClick=\"if ( !confirm ('Are you sure you want to purchase this $get_item[item_name] for $array[price] $pointsVar?') ) { return false; }\"><img src=$base_url/images/user_images/opg_$game/items/item_$get_item[id].gif><br><b>$get_item[item_name]</b><br>$array[stock] in Stock<br><i>$array[price] $pointsVar</i></A></p></td>";
	if ($y == 4)
	{
		echo "</tr>";
	}
	$x++;
}
print "</table></center>";

print "$closeHTML";
?>